home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 10597 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.4 KB  |  62 lines

  1. Path: news.cyberhighway.net!usenet
  2. From: lassiter@cyberhighway.net (lassiter)
  3. Newsgroups: comp.lang.c
  4. Subject: Could someone help me with this imbedded assembly code
  5. Date: 18 Mar 1996 21:54:49 GMT
  6. Organization: Your Organization
  7. Message-ID: <4ikm39$g8b@host-3.cyberhighway.net>
  8. NNTP-Posting-Host: dallaspm1-12.cyberhighway.net
  9. Mime-Version: 1.0
  10. Content-Type: Text/Plain; charset=US-ASCII
  11. X-Newsreader: WinVN 0.99.7
  12.  
  13. #include <iostream.h>
  14.  
  15. unsigned char scankey(void)
  16. {
  17.  asm{
  18.   mov ah, 01h
  19.   int 16h
  20.   jz empty;
  21.   mov ah, 00h
  22.   int 16h
  23.   mov al, ah
  24.   xor ah, ah
  25.   jmp done;
  26.   empty:
  27.    xor ax, ax
  28.   done:
  29.   }
  30.  }
  31. void main(void)
  32. {
  33.  unsigned char key = 'a';
  34.  do
  35.  {
  36.   cout << key << endl;
  37.   key = scankey();
  38.   } while (key != 'q');
  39.  }
  40.  
  41.   
  42.   Could someone tell me what is wrong with this code?  I am using Borland
  43.   C++ 3.0.  The errors I am getting are 
  44.  
  45.             error test.cpp 19: undefined label 'done'
  46.             error test.cpp 19: undefined label 'empty'
  47.             warning test.cpp 19: Function should return a value
  48.  
  49.      This program is supposed to display a character on each line and read
  50.    the keyboard buffer to see if a key had been pressed.  If a key was 
  51.    pressed it will then print that character instead.  It will repeat until
  52.    the q key is pressed.  Don't judge it too harshly, I'm only a beginner!
  53.  
  54.                                 Larry
  55.                                 lassiter@cyberhighway.net
  56.  
  57.  
  58.      
  59.  
  60.                        
  61.  
  62.